﻿using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Authorization;
using Simple.Common.Filters;

namespace Simple.WebApi.Controllers;

/// <summary>
/// 账号管理
/// </summary>
[Route("[controller]/[action]")]
[ApiController]
[DisabledRequestRecord]
public class AccountController : ControllerBase
{
    private readonly AccountService _accountService;

    public AccountController(AccountService accountService)
    {
        _accountService = accountService;
    }

    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="login"></param>
    /// <returns></returns>
    [HttpPost]
    public async Task<AppResult> QHSELogin([FromBody] QHSELoginModel login)
    {
        string token =await _accountService.QHSEGenerateTokenAsync(login);
        

        return AppResult.Status200OK("成功", token);
    }
    /// <summary>
    /// 获取用户信息
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [Authorize]
    public async Task<AppResult> QHSEGetUserInfo()
    { 
        var data = await _accountService.QHSEGetUserInfo();
        return AppResult.Status200OK(data: data);
    }
}
